<template>
    <div class="warehouse-details">
        <el-drawer v-model="dialogVisible" title="仓库详情" size="1200px" :with-header="false" direction="rtl">
            <div class="drawer-header">
                <div class="title">{{ props.dialogRow.title || 'XXX仓库' }}</div>
                <!-- <el-button plain @click="dialogVisible = false">
                    <el-icon>
                        <Close />
                    </el-icon>
                </el-button> -->
            </div>

            <div class="drawer-content">
                <div class="tab-header">
                    <div class="warehouse-info">
                        <div class="info-item">
                            <div class="label">仓库编号</div>
                            <div class="value">{{ props.dialogRow.code || 'XXXXXXXX' }}</div>
                        </div>
                        <div class="info-item">
                            <div class="label">库管人员</div>
                            <div class="value">{{ props.dialogRow.manager || '于非鱼' }}</div>
                        </div>
                        <div class="info-item">
                            <div class="label">联系人电话</div>
                            <div class="value">{{ props.dialogRow.phone || '13888888888' }}</div>
                        </div>
                        <div class="info-item">
                            <div class="label">仓库地址</div>
                            <div class="value">{{ props.dialogRow.address || 'XXXXXX' }}</div>
                        </div>
                        <div class="info-item">
                            <div class="label">库房类型</div>
                            <div class="value">{{ props.dialogRow.house_type_name || '汽车用品' }}</div>
                        </div>
                    </div>
                </div>

                <div class="tab-container">
                    <el-tabs v-model="activeTab">
                        <el-tab-pane label="基础信息" name="basic">
                            <div class="info-section">
                                <div class="section-title">
                                    <el-icon>
                                        <ArrowDown />
                                    </el-icon>
                                    <span>基础信息</span>
                                </div>
                                <div class="info-grid">
                                    <div class="info-row">
                                        <div class="info-col">
                                            <span class="label">订单类型</span>
                                            <span class="value">{{ props.dialogRow.title || 'XXXX仓库' }}</span>
                                        </div>
                                        <div class="info-col">
                                            <span class="label">采购单/出库退货单</span>
                                            <span class="value">{{ props.dialogRow.code || 'XXXXXX' }}</span>
                                        </div>
                                    </div>
                                    <div class="info-row">
                                        <div class="info-col">
                                            <span class="label">出库/采购退货日期</span>
                                            <span class="value">{{ props.dialogRow.house_type_name || '汽车用品' }}</span>
                                        </div>
                                        <div class="info-col">
                                            <span class="label">供应商/客户</span>
                                            <span class="value">{{ props.dialogRow.manager || '于非鱼' }}</span>
                                        </div>
                                    </div>
                                    <div class="info-row">
                                        <div class="info-col">
                                            <span class="label">采购/退货负责人</span>
                                            <span class="value">{{ props.dialogRow.phone || '18113994914' }}</span>
                                        </div>
                                        <div class="info-col">
                                            <span class="label">联系电话</span>
                                            <span class="value">{{ props.dialogRow.address || 'XXX路1号' }}</span>
                                        </div>
                                    </div>
                                    <div class="info-row">
                                        <div class="info-col ">
                                            <span class="label">状态</span>
                                            <span class="value">{{ props.dialogRow.remark || '优质供应商' }}</span>
                                        </div>
                                        <div class="info-col ">
                                            <span class="label">备注</span>
                                            <span class="value">{{ props.dialogRow.remark || '优质供应商' }}</span>
                                        </div>
                                    </div>
                                  
                                </div>
                            </div>

                            <div class="info-section">
                                <div class="section-title">
                                    <el-icon>
                                        <ArrowDown />
                                    </el-icon>
                                    <span>系统信息</span>
                                </div>
                                <div class="info-grid">
                                    <div class="info-row">
                                        <div class="info-col">
                                            <span class="label">创建人：</span>
                                            <span class="value">{{ props.dialogRow.creator || '张三' }}</span>
                                        </div>
                                        <div class="info-col">
                                            <span class="label">创建时间：</span>
                                            <span class="value">{{ props.dialogRow.create_time || '2023-12-01 13:32'
                                            }}</span>
                                        </div>
                                    </div>
                
                                </div>
                            </div>
                        </el-tab-pane>
           
                        <el-tab-pane label="入库产品" name="inbound-record">
                            <div class="record-content">
                                <div class="search-bar">
                                    <el-input v-model="recordSearch" placeholder="入库单号/订单类型/仓库名称" style="width: 300px">
                                        <template #prefix>
                                            <el-icon>
                                                <Search />
                                            </el-icon>
                                        </template>
                                    </el-input>
                                </div>
                                <div class=" inbound-list">
                                            <el-table :data="productList" border style=" width: 100%;">
                                                <el-table-column label="产品名称" prop="name" />
                                                <el-table-column label="规格型号" prop="model" />
                                                <el-table-column label="单位" prop="unit" width="80" align="center" />
                                                <el-table-column label="本次入库数量" prop="stock" align="center" />
                                                <el-table-column label="最低安全库存" prop="minStock" align="center" />
                                                <el-table-column label="备注" prop="remark" align="center" />
                                      
                                            </el-table>
                                        </div>

                               
                            </div>
                        </el-tab-pane>

         
                    </el-tabs>
                </div>
            </div>
        </el-drawer>
        </div>
       
</template>

<script setup lang="ts">
import { ref, computed } from 'vue';
import { ArrowDown, Close, Search, RefreshRight, Download, Plus, Expand, Fold } from '@element-plus/icons-vue';



const props = defineProps({
    dialogVisible: {
        type: Boolean,
        default: false
    },
    dialogRow: {
        type: Object,
        default: () => ({})
    }
});

const emit = defineEmits(['update:dialogVisible']);

const dialogVisible = computed({
    get: () => props.dialogVisible,
    set: (val) => emit('update:dialogVisible', val)
});

const activeTab = ref('basic');


const recordSearch = ref('');

// 产品库存数据
const productList = ref([
    {
        name: '华为笔记本电脑',
        code: 'HWPC0001',
        model: 'MateBook 15 D',
        unit: '个',
        stock: 680,
        minStock: 100,
        maxStock: 1000,
        image: 'https://example.com/image1.jpg'
    },
    {
        name: '罗技鼠标',
        code: 'LGSB00012',
        model: 'g520',
        unit: '个',
        stock: 5000,
        minStock: 1000,
        maxStock: 8000,
        image: 'https://example.com/image2.jpg'
    }
]);

</script>

<style lang="scss" scoped>
::v-deep .inventory-layout .product-category .category-list .el-menu-item.is-active {
    color: #6860FF !important;
    background-color: #6860ff15 !important;

}


//表格样式
::v-deep .product-list {
    .el-table {
        --el-table-header-bg-color: rgba(235, 236, 240, 1);

        th {
            color: #444;
            font-weight: bold;
        }
    }

}

//表格样式
::v-deep .inbound-list {
    .el-table {
        --el-table-header-bg-color: rgba(235, 236, 240, 1);

        th {
            color: #444;
            font-weight: bold;
        }
    }


}

//分页样式
.pagination {
    width: calc(100% - 1000px);
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding-top: 10px;

}


.warehouse-details {
    .drawer-header {
        padding: 16px 20px;
        border-bottom: 1px solid #E4E7ED;
        display: flex;
        justify-content: space-between;
        align-items: center;

        .title {
            font-size: 16px;
            font-weight: bold;
            color: #333;
        }
    }

    .drawer-content {
        height: calc(100% - 60px);
        overflow-y: auto;

        .tab-header {
            padding: 20px;
            background-color: #F5F7FA;

            .warehouse-info {
                display: flex;
                flex-wrap: wrap;
                gap: 16px;

                .info-item {
                    min-width: 200px;

                    .label {
                        color: #909399;
                        margin-right: 8px;
                        margin-bottom: 4px;
                    }

                    .value {
                        color: #333;
                        font-weight: 500;
                        font-size: 14px;
                    }
                }
            }
        }

        .tab-container {
            padding: 20px;

            :deep(.el-tabs__header) {
                margin-bottom: 20px;
            }
        }

        .info-section {
            margin-bottom: 24px;

            .section-title {
                background-color: #F5F7FA;
                padding: 12px 10px;
                display: flex;
                align-items: center;
                gap: 8px;
                margin-bottom: 16px;
                font-size: 14px;
                font-weight: bold;
                color: #333;

                .el-icon {
                    font-size: 16px;
                    color: #626aef;
                }
            }

            .info-grid {

                padding: 16px;
                border-radius: 4px;

                .info-row {
                    display: flex;
                    margin-bottom: 16px;

                    &:last-child {
                        margin-bottom: 0;
                    }

                    .info-col {
                        flex: 1;
                        display: flex;
                        align-items: center;

                        &.full-width {
                            flex: 2;
                        }

                        .label {
                            width: 80px;
                            color: #909399;
                            flex-shrink: 0;
                            margin-left: 10px;
                        }

                        .value {
                            color: #333;
                            flex: 1;
                            display: inline-block;
                            padding: 6px;
                            font-size: 14px;
                            background-color: #F5F7FA;
                        }
                    }
                }
            }
        }
    }
}

:deep(.el-drawer) {
    .el-drawer__body {
        padding: 0;
    }
}

:deep(.el-tabs__nav-wrap::after) {
    height: 1px;
}

:deep(.el-tabs__active-bar) {
    background-color: #626aef;
}

:deep(.el-tabs__item.is-active) {
    color: #626aef;
}

:deep(.el-tabs__item:hover) {
    color: #626aef;
}

.search-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;

    .right-buttons {
        display: flex;
        gap: 8px;
    }

    .filter-buttons {
        margin-left: 16px;
    }
}

.product-list,
.inbound-list,
.record-list {
    margin-bottom: 16px;
}

.pagination {
    display: flex;
    justify-content: flex-end;
    padding: 16px 0;
}

:deep(.el-table) {
    --el-table-header-bg-color: #F5F7FA;

    th {
        background-color: var(--el-table-header-bg-color);
        color: #606266;
        font-weight: 500;
    }
}

:deep(.el-button) {
    &.is-plain {
        &:hover {
            color: #626aef;
            border-color: #626aef;
        }
    }
}

:deep(.el-radio-button__orig-radio:checked + .el-radio-button__inner) {
    background-color: #626aef;
    border-color: #626aef;
    box-shadow: -1px 0 0 0 #626aef;
}

.inventory-layout {
    display: flex;
    height: 100%;

    .product-category {
        width: 200px;
        border-right: 1px solid var(--el-border-color-light);
        transition: width 0.3s;
        background-color: rgb(245, 247, 249);
        padding: 0px 12px;
        margin-right: 10px;

        &.is-collapsed {
            width: 0;
            overflow: hidden;
        }

        .category-header {
            padding: 12px 16px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--el-border-color-light);

            .header-title {
                display: flex;
                align-items: center;
                gap: 90px;
                justify-content: space-between;
                font-size: 14px;
                font-weight: 500;
            }
        }

        .category-search {
            padding: 12px;
            border-bottom: 1px solid var(--el-border-color-light);
        }

        .category-list {
            .el-menu {
                border-right: none;
            }

            .el-menu-item {
                height: 40px;
                line-height: 40px;

                &.is-active {
                    background-color: var(--el-color-primary-light-9);
                    color: var(--el-color-primary);
                }
            }
        }
    }

    .product-content {
        flex: 1;

        transition: margin-left 0.3s;

        &.is-expanded {
            margin-left: 0;
        }

        .search-bar {
            margin-bottom: 16px;
        }
    }
}

// 表格样式优化
.product-list {
    :deep(.el-table) {
        --el-table-header-bg-color: #F5F7FA;

        th {
            background-color: var(--el-table-header-bg-color);
            color: #606266;
            font-weight: 500;
        }
    }
}

.accordion-item {
    border-radius: 4px;
    background: rgb(244, 245, 247);
    margin-bottom: 16px;


    overflow: hidden;
}

.accordion-header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 48px;
    cursor: pointer;
    background: rgb(244, 245, 247);
    margin-bottom: 6px;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    transition: background 0.2s;
    .arrow {
        margin-right: 12px;
        transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
        color: #999;
        &.expanded {
            transform: rotate(90deg);
            color: #626aef;
        }
    }
    &.expanded {
        background: #f5f7fa;
    }
    .main-field {
        margin-right: 32px;
        min-width: 140px;
        white-space: nowrap;
    }
}

.accordion-body {
    padding: 0 0 20px 0;
    background: #fff;
    animation: fadeIn 0.3s;
}

.expand-enter-active, .expand-leave-active {
    transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.3s;
    overflow: hidden;
}
.expand-enter-from, .expand-leave-to {
    max-height: 0;
    opacity: 0;
}
.expand-enter-to, .expand-leave-from {
    max-height: 500px;
    opacity: 1;
}

.status-un {
    color: #666;
}
.status-part {
    color: #ff9900;
}
.status-all {
    color: #13ce66;
}

.operation-list {
    padding: 16px 0 0 0;
}
.operation-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    font-size: 15px;
    border-bottom: 1px solid #f5f5f5;
    &:last-child {
        border-bottom: none;
    }
    .avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        object-fit: cover;
        margin-right: 16px;
        background: #f5f7fa;
        border: 1px solid #eee;
    }
    .user {
        color: #333;
        font-weight: 500;
        margin-right: 18px;
    }
    .warehouse {
        color: #666;
        margin-right: 18px;
    }
    .time {
        color: #999;
        margin-right: 24px;
        font-size: 14px;
    }
    .desc {
        color: #333;
        .order-link {
            color: #144b9e;
            cursor: pointer;
            margin-left: 2px;
            &:hover {
                text-decoration: underline;
                color: #3a5fff;
            }
        }
    }
}
</style>
